﻿using System;
using Microsoft.Xna.Framework.Audio;
using Terraria.Utilities;

namespace Terraria.Audio
{
	// Token: 0x0200049D RID: 1181
	public class LegacySoundStyle : SoundStyle
	{
		// Token: 0x170002CF RID: 719
		// (get) Token: 0x0600278F RID: 10127 RVA: 0x0001BAE4 File Offset: 0x00019CE4
		public int Style
		{
			get
			{
				if (this._styleVariations != 1)
				{
					return LegacySoundStyle._random.Next(this._style, this._style + this._styleVariations);
				}
				return this._style;
			}
		}

		// Token: 0x170002D0 RID: 720
		// (get) Token: 0x06002790 RID: 10128 RVA: 0x0001BB13 File Offset: 0x00019D13
		public int Variations
		{
			get
			{
				return this._styleVariations;
			}
		}

		// Token: 0x170002D1 RID: 721
		// (get) Token: 0x06002791 RID: 10129 RVA: 0x0001BB1B File Offset: 0x00019D1B
		public int SoundId
		{
			get
			{
				return this._soundId;
			}
		}

		// Token: 0x170002D2 RID: 722
		// (get) Token: 0x06002792 RID: 10130 RVA: 0x0001BB23 File Offset: 0x00019D23
		public override bool IsTrackable
		{
			get
			{
				return this._soundId == 42;
			}
		}

		// Token: 0x06002793 RID: 10131 RVA: 0x0001BB2F File Offset: 0x00019D2F
		public LegacySoundStyle(int soundId, int style, SoundType type = SoundType.Sound) : base(type)
		{
			this._style = style;
			this._styleVariations = 1;
			this._soundId = soundId;
		}

		// Token: 0x06002794 RID: 10132 RVA: 0x0001BB4D File Offset: 0x00019D4D
		public LegacySoundStyle(int soundId, int style, int variations, SoundType type = SoundType.Sound) : base(type)
		{
			this._style = style;
			this._styleVariations = variations;
			this._soundId = soundId;
		}

		// Token: 0x06002795 RID: 10133 RVA: 0x0001BB6C File Offset: 0x00019D6C
		private LegacySoundStyle(int soundId, int style, int variations, SoundType type, float volume, float pitchVariance) : base(volume, pitchVariance, type)
		{
			this._style = style;
			this._styleVariations = variations;
			this._soundId = soundId;
		}

		// Token: 0x06002796 RID: 10134 RVA: 0x0001BB8F File Offset: 0x00019D8F
		public LegacySoundStyle WithVolume(float volume)
		{
			return new LegacySoundStyle(this._soundId, this._style, this._styleVariations, base.Type, volume, base.PitchVariance);
		}

		// Token: 0x06002797 RID: 10135 RVA: 0x0001BBB5 File Offset: 0x00019DB5
		public LegacySoundStyle WithPitchVariance(float pitchVariance)
		{
			return new LegacySoundStyle(this._soundId, this._style, this._styleVariations, base.Type, base.Volume, pitchVariance);
		}

		// Token: 0x06002798 RID: 10136 RVA: 0x0001BBDB File Offset: 0x00019DDB
		public LegacySoundStyle AsMusic()
		{
			return new LegacySoundStyle(this._soundId, this._style, this._styleVariations, SoundType.Music, base.Volume, base.PitchVariance);
		}

		// Token: 0x06002799 RID: 10137 RVA: 0x0001BC01 File Offset: 0x00019E01
		public LegacySoundStyle AsAmbient()
		{
			return new LegacySoundStyle(this._soundId, this._style, this._styleVariations, SoundType.Ambient, base.Volume, base.PitchVariance);
		}

		// Token: 0x0600279A RID: 10138 RVA: 0x0001BC27 File Offset: 0x00019E27
		public LegacySoundStyle AsSound()
		{
			return new LegacySoundStyle(this._soundId, this._style, this._styleVariations, SoundType.Sound, base.Volume, base.PitchVariance);
		}

		// Token: 0x0600279B RID: 10139 RVA: 0x0001BC4D File Offset: 0x00019E4D
		public bool Includes(int soundId, int style)
		{
			return this._soundId == soundId && style >= this._style && style < this._style + this._styleVariations;
		}

		// Token: 0x0600279C RID: 10140 RVA: 0x0001BC73 File Offset: 0x00019E73
		public override SoundEffect GetRandomSound()
		{
			if (this.IsTrackable)
			{
				return Main.trackableSounds[this.Style];
			}
			return null;
		}

		// Token: 0x040043CE RID: 17358
		private static UnifiedRandom _random = new UnifiedRandom();

		// Token: 0x040043CF RID: 17359
		private int _style;

		// Token: 0x040043D0 RID: 17360
		private int _styleVariations;

		// Token: 0x040043D1 RID: 17361
		private int _soundId;
	}
}
